﻿<Window x:Class="ManageCategoriesProducts.EditCategoryWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ManageCategoriesProducts"
        Title="Edit category" Height="149" Width="369">
    <Window.Resources>
        <local:ConvertBooleanToIsEnabled x:Key="convertBooleanToIsEnabled" />
        <local:NegateConverter x:Key="NegateConverter" />
    </Window.Resources>
    <Grid>
        <Label Content="Category name:" Height="28" HorizontalAlignment="Left" Margin="21,13,0,0" 
               Name="labelEventName" VerticalAlignment="Top" Width="99"/>
       
        <TextBox Height="23" HorizontalAlignment="Left" Margin="115,15,0,0" VerticalAlignment="Top" Width="224"
                 x:Name="TextBoxCategoryName">
            <TextBox.Text>
                <Binding Path="CategoryName" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <local:ValidateCategory MinLength="1" MaxLength="20"
                            ErrorMessage="Event name length must be between 1 and 20" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        <TextBlock Foreground="Red" FontWeight="Bold" Margin="0,41,0,43" 
                   Text="{Binding ElementName=TextBoxCategoryName, 
                                 Path=(Validation.Errors),  
                                 Converter={local:ValidationErrorsToStringConverter}}"/>
        <Button Content="Edit" Height="23" HorizontalAlignment="Left" Margin="155,73,0,0"                 
                Name="buttonEdit" VerticalAlignment="Top" Width="75" Click="buttonEdit_Click"
                IsEnabled="{Binding ElementName=TextBoxCategoryName, Path=(Validation.HasError),
                                Converter={StaticResource NegateConverter}}" >
            <!--IsEnabled="{Binding ElementName=dataGridCategories, Path=SelectedItem, 
                            Converter={StaticResource ResourceKey=converterIsEnabled}}"-->
            <!--<Button.IsEnabled>
                <MultiBinding Converter="{StaticResource convertBooleanToIsEnabled}">
                    <Binding ElementName="textBoxPrice" Path="(Validation.HasError)" />
                    <Binding ElementName="textBoxEventName" Path="(Validation.HasError)" />
                    <Binding ElementName="datePickerDate" Path="(Validation.HasError)" />
                </MultiBinding >
            </Button.IsEnabled>-->
        </Button>
        <Button Content="Cancel" Height="23" HorizontalAlignment="Left" Margin="245,73,0,0" 
                Name="buttonCancel" VerticalAlignment="Top" Width="75" Click="buttonCancel_Click" />
    </Grid>
</Window>
